<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <div>
            <label>姓名：</label>
            <input type="text" id="name" name="name">
        </div>
        <div>
            <label>专业：</label>
            <select name="major" id="major">
                <option value="1">JAVA</option>
                <option value="2">WEB前端</option>
            </select>
        </div>
        <div>
            <button id="btn">确认</button>
            <button id="btn2">设置</button>
        </div>
    </div>
</body>
<script>
    let inputName = document.querySelector("#name");
    let selectMajor = document.querySelector("#major");
    let btn = document.querySelector("#btn");
    let btn2 = document.querySelector("#btn2");

    btn.addEventListener("click",function() {
        // value属性，获取文本框，文本域，下拉框的值
        let name = inputName.value;
        let major = selectMajor.value;
        console.log("name = ",name,",major = ",major);
    });

    btn2.addEventListener("click",function() {
        inputName.value = "张三";
        selectMajor.value = "2";
    })
</script>
</html>